package com.way.cloud.controller;

import com.way.cloud.feign.EchoFeign;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class EchoController {

    @Resource
    private RestTemplate restTemplate;
    @Resource
    private EchoFeign echoFeign;

    @GetMapping("/echo-rest/{message}")
    public String echoRest(@PathVariable(name = "message") String message) {
        return restTemplate.getForObject("http://example-provider/echo/" + message, String.class) + " @RestTemplate";
    }

    @GetMapping(value = "/echo-feign/{message}")
    public String echoFeign(@PathVariable(name = "message") String message) {
        return echoFeign.echo(message) + " @Feign";
    }

}
